/*
 * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2019. All rights reserved.
 * Description: algadapter adas for adasplus implementation
 * Author: HiMobileCam Reference Develop Team
 * Create: 2019-11-01
 */

#include "algadapter_adas_dummy.h"
#include <memory.h>
#include "hi_appcomm.h"
#include "hi_algadapter_adas.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */

static HI_S32 AdasAlgoGetCapability(HiAdasCapability* capability)
{
    HI_APPCOMM_CHECK_POINTER(capability, HI_ALGADAPTER_ADAS_EINVAL);
    capability->capMask = HI_ADAS_CAP_LDW | HI_ADAS_CAP_FCW | HI_ADAS_CAP_FCR;
    capability->imgTypeMask = HI_AIENGINE_IMAGE_TYPE_YVU420SP;
    capability->inputImgHeight = 288; /* alg support height 288 */
    capability->inputImgWidth  = 512; /* alg support width  512 */
    capability->maxFps         = 10;  /* alg support maxFps 10  */

    MLOGD("inputImgHeight(%d), inputImgWidth(%d), maxFps(%d), mask(ldw/fcw), imgTpe(YVU420SP)\n",
        capability->inputImgHeight, capability->inputImgWidth, capability->maxFps);

    return HI_SUCCESS;
}

static HI_S32 AdasAlgoInit(const HiAdasAlgoPara* initPara)
{
    HI_APPCOMM_CHECK_POINTER(initPara, HI_ALGADAPTER_ADAS_EINVAL);
    return HI_SUCCESS;
}

static HI_S32 AdasAlgoDeinit()
{
    return HI_SUCCESS;
}

static HI_S32 AdasAlgoProcessImage(const HiAdasImage* image, HiAdasAlgoProcessResult* result)
{
    HI_APPCOMM_CHECK_POINTER(image, HI_ALGADAPTER_ADAS_EINVAL);
    HI_APPCOMM_CHECK_POINTER(result, HI_ALGADAPTER_ADAS_EINVAL);

    memset(result, 0, sizeof(HiAdasAlgoProcessResult));
    result->isCalibrated = HI_TRUE;
    return HI_SUCCESS;
}

static HI_S32 AdasAlgoSetAttr(HiAdasAttrType type, const HiAdasAttr* attr)
{
    HI_APPCOMM_CHECK_POINTER(attr, HI_ALGADAPTER_ADAS_EINVAL);
    return HI_SUCCESS;
}

static HI_S32 AdasAlgoGetAttr(HiAdasAttrType type, HiAdasAttr* attr)
{
    HI_APPCOMM_CHECK_POINTER(attr, HI_ALGADAPTER_ADAS_EINVAL);
    if(type == HI_ADAS_ATTR_CALIBRATE) {
        attr->caliAttr.isCalibrated = HI_TRUE;
        attr->caliAttr.vanishPoint.x = 256; /* fake width  256 */
        attr->caliAttr.vanishPoint.x = 144; /* fake height 144 */
    }
    return HI_SUCCESS;
}

static HI_S32 AdasAlgoInvoke(HI_U32 cmd, const HiAdasCmdPara* cmdPara)
{
    HI_APPCOMM_CHECK_POINTER(cmdPara, HI_ALGADAPTER_ADAS_EINVAL);
    return HI_SUCCESS;
}

/* adasplus adas algorithm struct */
HiAdasAlgorithm g_dummyAdasAlg = {
    .algoName = "dummy",
    .GetCapability = AdasAlgoGetCapability,
    .Init = AdasAlgoInit,
    .Deinit = AdasAlgoDeinit,
    .ProcessImage = AdasAlgoProcessImage,
    .SetAttr = AdasAlgoSetAttr,
    .GetAttr = AdasAlgoGetAttr,
    .Invoke = AdasAlgoInvoke,
};

HiAdasAlgorithm *ALGADAPTER_DUMMY_GetAdasAlgorithm()
{
    return &g_dummyAdasAlg;
}

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
